<template>
  <el-row class="my-row-v">
    <el-col :span="8">
      <el-select v-model="v1" :disabled="disabled" @change="handleV1Change">
        <el-option
          v-for="item in v1Options"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        />
      </el-select>
    </el-col>
    <el-col :span="8">
      <el-input-number
        v-model="v2"
        :disabled="disabled"
        :min="0"
        :max="9"
        controls-position="right"
        @change="handleV2Change"
      />
    </el-col>
  </el-row>
</template>

<script>
import { getA_ZArray, get0_9Array } from '@/utils'
import { number } from '@/views/cms/js'

export default {
  props: {
    disabled: {
      type: Boolean,
      default: false
    },
    value: {
      type: String,
      default: 'A0'
    },
    DocumentVersionData: {},
    versionChange: {
      type: Function,
      default: () => {
        return Function
      }
    }
  },

  mounted() {
    this.v1Options = getA_ZArray()
    for (let i = 0; i < 10; i++) {
      const c = i
      this.v2Options.push({ value: c, label: c })
    }
  },

  data() {
    return {
      v1Options: [],
      v2Options: [],
      v1: 'A',
      v2: ''
    }
  },
  watch: {
    DocumentVersionData(data) {
      // if (data.type == '1') {
      //   this.v1Options = get0_9Array()
      //   this.v1 = '0'
      //   this.v2 = '1'
      //   this.$emit('inputData', this.v1 + this.v2)
      //   this.$forceUpdate()
      // } else if (data.type == '0') {
      //   this.v1Options = getA_ZArray()
      //   this.v1 = 'A'
      //   this.v2 = '0'
      //   this.$emit('inputData', this.v1 + this.v2)
      //   this.$forceUpdate()
      // }
    }
  },
  methods: {
    handleV1Change(val) {
      this.v1 = val
      const data = this.v1 + this.v2
      this.$emit('inputData', data)
    },
    handleV2Change(currentVal, oldVal) {
      this.v2 = currentVal
      const data = this.v1 + this.v2
      this.$emit('inputData', data)
    },
    refreshVersion(v1, v2, index) {
      console.log(v1, v2, index)
      // if (v2 === '9') {
      //   this.v1 = String.fromCharCode(v1 + 1)
      //   this.v2 = 0
      //   console.log(this.v1, '1')
      // } else {
      this.v1 = v1
      this.v2 = Number(v2) + 1
      // }

      const data = { version: this.v1 + this.v2, index }
      this.$emit('inputData', data)
    }
  }
}
</script>
<style lang="scss" scoped>
</style>
